<template>
	<view class="page">
		<uv-navbar
			:leftIconColor="navstyle.txtColor"
			:titleStyle="titleStyle"
			:title="navstyle.title"
			:leftIcon="navstyle.leftIcon"
			:bgColor="navstyle.bgColor"
			:fixed="false"  
			@leftClick="leftClick"
			:safeAreaInsetTop="false">
		</uv-navbar>
		<view class="management">
			<view class="balance">
				<view class="ba_use">
					余额
					<view class="uni-image"></view>
				</view>
				<view class="ba_money">
					<text style="font-size: 12px;">余额:</text>
					<text style="font-size: 18px;display: inline-block;">{{userInfo.money}}</text>
				</view>
				
				<view class="ba_money">
					<text style="font-size: 12px;">佣金:</text>
					<text style="font-size: 18px;display: inline-block;">{{userInfo.score}}</text>
				</view>
			</view>
			<view class="ma_box">
				<view class="boxfi" v-for="(item,index) in moneyList" :key="index" @click="moneyClick(item)">
					<image  class="uni-image" :src="item.src" :mode="item.mode"></image>
					 {{item.title}}
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	import {memberInfo,qgDetail} from '@/api/user.js';
	export default{
		data(){
			return{
				navstyle: {
					title: "我的钱包",
					txtColor: "#333333",
					bgColor: "#FFFFFF",
					leftIcon: "arrow-left"
				},
				titleStyle: {
					fontWeight: 700
				},
				userInfo:{},
				txswitch:"",
				moneyList:[
					{
						mode:"scaleToFill",
						src:'../../static/images/ass_chong.png',
						title:"充值",
						url:'/pages/user/moneyRecharge'
					},
					{
						mode:"scaleToFill",
						src:'../../static/images/zhuan_z.png',
						title:"转账",
						url:'/pages/user/transfer'
					},
					{
						mode:"scaleToFill",
						src:'../../static/images/ass_tixian.png',
						title:"提现",
						url:'/pages/user/extract'
					}
					
				]
			}
		},
		onLoad() {
			memberInfo().then(response=>{
				this.userInfo = response.data;
				console.log(this.userInfo)
			});
			qgDetail().then(response=>{
				this.txswitch = response.data.txswitch;
				console.log(this.txswitch)
			});
			
		},
		methods:{
			leftClick() {
				uni.reLaunch({
				  url: '/pages/index/user' // 替换成上一页的路径
				});
			},
			moneyClick(item){
				if(item.title == "转账"){
					uni.showToast({
						title: '未开放',
						duration: 2000
					});
					return
				}
				if(this.txswitch != 1 && item.title == "提现"){
					uni.showToast({
						title: '未开放',
						duration: 2000
					});
					return
				}
				uni.navigateTo({
					url:item.url
				})	
			}
		}
	}
	
</script>

<style>
	.page{
		width: 100%;
		height: 100%;
	    background-color: #fafafa;
	}
	.balance{
	    position: relative;
	    width: 84%;
	    margin: 10px auto;
	    background: linear-gradient(135deg, #d66c6b, #ed6266);
	    border-radius: 10px;
	    color: #fff;
	    padding: 0 21px;
	}
	.ma_box{
	    display: flex;
	    justify-content: space-between;
	    width: 85%;
	    margin: 10px auto;
	    padding: 16px 21px;
	    border-radius: 10px;
	    background-color: #fff;
	    font-size: 16px;
	}
	.ba_use .uni-image {
	    width: 21px;
	    height: 21px;
	    margin-top: 12px;
	    margin-left: 16px;
	    background-image: url(/static/img/user/eye.png);
	    background-size: 100% 100%;
	}
	.ba_use{
	    display: flex;
	    line-height: 42px;
	    font-size: 17px;
	}
	.ba_money {
	    font-size: 32px;
	    padding-bottom: 10px;
	    margin-right: 10px;
	}
	.boxfi{
	    display: flex;
	    flex-wrap: nowrap;
	    text-align: center;
	    line-height: 37px;
	    align-items: center;
	}
	.boxfi image {
	    width: 21px;
	    height: 21px;
	    margin-right: 5px;
	}
</style>